﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using BAL;
using Common;
namespace Web
{
    public partial class AreaChartMain : System.Web.UI.Page
    {
        protected int examroomid = 0, areaid = 0;
        protected string ExamRoomId = "";
        protected string AreaName = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!UserValidate.CheckLogin(this.Request, "StatistScore"))
            {
                Response.Write("<script type=\"text/javascript\">top.location.href='login.aspx';</script>");
                Response.Redirect("login.aspx");
                Response.End();
            }

            if (!PageValidate.QueryStringIsEmpty("areaid"))
            {
                try
                {
                    areaid = int.Parse(PageValidate.QueryString("areaid"));
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                    Response.End();
                }
            }
            if (!PageValidate.QueryStringIsEmpty("examroomid"))
            {
                try
                {
                    examroomid = int.Parse(PageValidate.QueryString("examroomid"));
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                    Response.End();
                }
            }
            if (!IsPostBack)
            {
                if (examroomid > 0 && areaid > 0)
                {
                    ExamRoomInfo examroominfo = ExamRoom.GetSingleInfo(examroomid);
                    AreaInfo areaInfo = Area.GetSingleInfo(areaid);
                    if (examroominfo != null && areaInfo != null)
                    {
                        AreaName = areaInfo.Name;
                        ExamRoomId = examroominfo.CreateDate.ToShortDateString() + "-" + examroominfo.Id.ToString();
                    }
                    else
                    {
                        Response.Redirect("AdminExamRoom.aspx");
                    }
                }
                else
                {
                    Response.Redirect("AdminExamRoom.aspx");
                }
            }
        }
    }
}
